<template>
  <a-modal :open="open" width="550px" title="手术并发症维护" centered @ok="onOk" @cancel="onCancel">
    <a-form class="mt-5" :model="formState" name="validate_other" v-bind="formItemLayout" :label-col="{ span: 4 }">
      <a-form-item label="编号">
        <a-input v-model:value="formState.bh" placeholder="请输入" :disabled="rowData.bh ? true : false" />
      </a-form-item>
      <a-form-item label="名称">
        <a-input v-model:value="formState.mc" placeholder="请输入" />
      </a-form-item>
      <a-form-item label="顺序号">
        <a-input v-model:value="formState.outorder" placeholder="请输入" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>
<script setup>
import { ref, watch } from 'vue'
import { message } from 'ant-design-vue'
import { post } from '@/utils/request'

const formState = ref({})
const props = defineProps({
  open: {
    type: Boolean,
    default: false
  },
  rowData: {
    type: Object,
    default: () => ({})
  }
})
const onOk = async () => {
  const { code, msg } = await post('operation/opex/doSaveOperationComplicationInfo', formState.value)
  if (code === 0) {
    message.success(msg)
    emit('update:open', false)
    emit('success')
  }
}
const emit = defineEmits(['update:open', 'confirm', 'success'])

const onCancel = () => {
  open.value = false
  emit('confirm')
}
watch(
  () => props.rowData,
  (val) => {
    console.log(val)
    if (val) {
      formState.value = { ...val }
    }
  },
  {
    immediate: true
  }
)
</script>
